<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>退货</title>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
</head>
<body>
	<script type="text/javascript">
		$(function() {
			//打开退货窗口
			$("#lfq-drug-btn-th").linkbutton({onClick:function(){
				$("#lfq-win-drugTuiHuo").window("open");
			}});
			
			//双击添加行
			$("#lfq-tb-drugTuihuo1").datagrid({onDblClickRow:function(index, row){
				var rows=$("#lfq-tb-drugTuihuo2").datagrid("getRows");
				var kk=0;
				if(rows.length>0){
					for(var i=0;i<rows.length;i++){
						if(row.thNo==rows[i].thNo){
							kk++;
						}
					}
					if(kk==0){
						$('#lfq-tb-drugTuihuo2').datagrid('appendRow', {
							'thNo' : [row.thNo],
							'cqName' : [row.cqName],
							'thNumber' : [row.thNumber],
							'cgPrice' : [row.cgPrice],
							'thMoney' : [row.thMoney],
							'thState' : [row.thState],
							'thSupplier' : [row.thSupplier],
							'thTel' : [row.thTel]
						});
					}else{
						$.messager.alert("提示", "该条记录已经添加了！");
					}
				}else{
					$('#lfq-tb-drugTuihuo2').datagrid('appendRow', {
						'thNo' : [row.thNo],
						'cqName' : [row.cqName],
						'thNumber' : [row.thNumber],
						'cgPrice' : [row.cgPrice],
						'thMoney' : [row.thMoney],
						'thState' : [row.thState],
						'thSupplier' : [row.thSupplier],
						'thTel' : [row.thTel]
					});
				}
				
			}});
			
			//双击删除行
			$("#lfq-tb-drugTuihuo2").datagrid({onDblClickRow:function(index, row){
				$("#lfq-tb-drugTuihuo2").datagrid("deleteRow",index);
			}});
			
			//退货
			$("#lfq-btn-Drug-tuihuoOk").linkbutton({onClick:function(){
				var rows=$("#lfq-tb-drugTuihuo2").datagrid("getRows");
				var arrs=[];
				if(rows.length>0){
					for(var i=0;i<rows.length;i++){
						arrs.push(rows[i].thNo);
					}
					$("<form>").form('submit', {
						url:"drugTuoHuoById",
						onSubmit : function(param) {
							param.arr = arrs;
						},
						success : function(data) {//
							var json = eval("(" + data + ")");
							$('#lfq-tb-drugTuihuo1').datagrid("reload");
							for(var i=rows.length-1;i>=0;i--){
								var ind=$("#lfq-tb-drugTuihuo2").datagrid("getRowIndex",rows[i]);
								$("#lfq-tb-drugTuihuo2").datagrid("deleteRow",ind);
							}
							$('#lfq-tb-drugTuihuo2').datagrid("reload");
							$('#lfq-tb-drugTuihuo').datagrid("reload");
							$.messager.alert("提示", json.reason);
						}
					});
				}else{
					$.messager.alert("提示", "请先添加！");
				}
			}});

		});
	</script>

	<!-- 退货 -->
	<table id="lfq-tb-drugTuihuo" class="easyui-datagrid"
		data-options="url:'selectReturngoodsDrug',
			fitColumns:true,
			fit:true,
			pagination: true,
			pageSize: 5,
			pageList: [5, 10, 15, 20],
			rownumbers: true,
			toolbar: '#lfq-tool-tuihuo',
			border:false
			">
		<thead>
			<tr>
				<th data-options="field:'thNo',width:'9%'">退货ID</th>
				<th data-options="field:'cqName',width:'16%'">药品名称</th>
				<th data-options="field:'thNumber',width:'9%'">退货数量</th>
				<th data-options="field:'cgPrice',width:'9%'">价格</th>
				<th data-options="field:'thMoney',width:'9%'">总金额</th>
				<th data-options="field:'thState',width:'9%'">退货状态</th>
				<th data-options="field:'thTime',width:'9%'">退货时间</th>
				<th data-options="field:'thSupplier',width:'16%'">退货公司</th>
				<th data-options="field:'thTel',width:'9%'">联系电话</th>
			</tr>
		</thead>
	</table>

	<div id="lfq-tool-tuihuo">
		<a id="lfq-drug-btn-th" class="easyui-linkbutton"
			data-options="iconCls:'icon-tuihuo',plain:true">药品退货</a>
	</div>

	<!-- 药品退货窗口 -->
	<div id="lfq-win-drugTuiHuo" class="easyui-window" title="药品退货"
		data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true"
		style="width: 800px; height: 540px; padding: 5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding: 10px;">
				<div class="easyui-layout" data-options="fit:true">
					<div data-options="region:'center'" style="padding: 10px;height: 50%">
						<table id="lfq-tb-drugTuihuo1" class="easyui-datagrid"
							data-options="url:'selectReturngoodsDrugWeiWc',
								fitColumns:true,
								fit:true,
								pagination: true,
								pageSize: 5,
								pageList: [5, 10, 15, 20],
								rownumbers: true,
								border:false
								">
							<thead>
								<tr>
									<th data-options="field:'thNo',width:'10%'">退货ID</th>
									<th data-options="field:'cqName',width:'18%'">药品名称</th>
									<th data-options="field:'thNumber',width:'10%'">退货数量</th>
									<th data-options="field:'cgPrice',width:'10%'">价格</th>
									<th data-options="field:'thMoney',width:'10%'">总金额</th>
									<th data-options="field:'thState',width:'10%'">退货状态</th>
									<th data-options="field:'thSupplier',width:'18%'">退货公司</th>
									<th data-options="field:'thTel',width:'12%'">联系电话</th>
								</tr>
							</thead>
						</table>
					</div>
					<div data-options="region:'south'" style="padding: 10px;height: 50%">
						<table id="lfq-tb-drugTuihuo2" class="easyui-datagrid"
							data-options="
								fitColumns:true,
								fit:true,
								rownumbers: true,
								border:false
								">
							<thead>
								<tr>
									<th data-options="field:'thNo',width:'10%'">退货ID</th>
									<th data-options="field:'cqName',width:'18%'">药品名称</th>
									<th data-options="field:'thNumber',width:'10%'">退货数量</th>
									<th data-options="field:'cgPrice',width:'10%'">价格</th>
									<th data-options="field:'thMoney',width:'10%'">总金额</th>
									<th data-options="field:'thState',width:'10%'">退货状态</th>
									<th data-options="field:'thSupplier',width:'18%'">退货公司</th>
									<th data-options="field:'thTel',width:'12%'">联系电话</th>
								</tr>
							</thead>
						</table>
					</div>
				</div>
			</div>
			<div data-options="region:'south',border:false"
				style="text-align: right; padding: 5px 0 0;">
				<a id="lfq-btn-Drug-tuihuoOk" class="easyui-linkbutton"
					data-options="iconCls:'icon-ok', plain:true">退货</a> <a
					class="easyui-linkbutton"
					data-options="iconCls:'icon-cancel', plain:true"
					href="javascript:$('#lfq-win-drugTuiHuo').window('close');"
					onclick="">取消</a>
			</div>
		</div>
	</div>

</body>
</html>